<script>
	let m = { x: 0, y: 0 };

	function handleMousemove(event) {
		m.x = event.clientX;
		m.y = event.clientY;
	}
	//-------------------------------------
	function handleClick() {
		alert('no more alerts');
	}
	//-------------------------------------

	// import Inner from './components/Inner.svelte'
	import Outer from './components/outer.svelte';
	function handleMessage(event) {
		alert(event.detail.text);
	}
	//---------------------------------------------------
	import FancyButton from './components/FancyButton.svelte';
	function bhandleClick() {
		alert('clicked');
	}
</script>

<div on:mousemove={handleMousemove}>The mouse position is {m.x} x {m.y}</div>
<hr class="w-full bg-white border" />
<div on:mousemove={(e) => (m = { x: e.clientX, y: e.clientY })}>
	The mouse position is {m.x} x {m.y}
</div>
//行内事件<button on:click|once={handleClick}> Click me </button>//事件只执行一次
<!-- <Inner on:message={handleMessage} /> -->
<Outer on:message={handleMessage} />
//组件事件 绑定传递
<FancyButton on:click={bhandleClick} />//DOM事件

<style>
	div {
		width: 100%;
		height: 100%;
	}
</style>
